package com.oocl.euc.core.maintenance.model;

import com.oocl.euc.audit.AuditEntity;

import javax.persistence.*;
import java.util.HashSet;
import java.util.Set;

@Entity
@Table(name = "PCRS_ROLES")
@SequenceGenerator(name = "SEQUENCE_GENERATOR", sequenceName = "ROLES_SEQUENCE", allocationSize = 1)
public class Role extends AuditEntity {

    @Column(name = "ROLE_NAME")
    private String roleName;

    @Column(name = "ROLE_DESC")
    private String roleDesc;

    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
    @JoinColumn(name = "role_id", referencedColumnName = "ID")
    private Set<RoleAuth> roleAuths = new HashSet<>();

    public Role() {
    }

    public Role(String roleName, String roleDesc) {
        this.roleName = roleName;
        this.roleDesc = roleDesc;
    }

    public String getRoleName() {
        return roleName;
    }

    public void setRoleName(String roleName) {
        this.roleName = roleName;
    }

    public String getRoleDesc() {
        return roleDesc;
    }

    public void setRoleDesc(String roleDesc) {
        this.roleDesc = roleDesc;
    }

    public Set<RoleAuth> getRoleAuths() {
        return roleAuths;
    }

    public void setRoleAuths(Set<RoleAuth> roleAuths) {
        this.roleAuths = roleAuths;
    }

    @Override
    public void setId(Long id) {
        super.setId(id);
    }
}
